31. Quiz: CASE
Questions: CASE
Use the SQL environment below to assist with answering the following questions. Whether you get stuck or you just want to double check your solutions, my answers can be found at the top of the next concept.
Write a query to display for each order, the account ID, total amount of the order, and the level of the order - ‘Large’ or ’Small’ - depending on if the order is $3000 or more, or smaller than $3000.
Write a query to display the number of orders in each of three categories, based on the
total
number of items in each order. The three categories are: 'At Least 2000', 'Between 1000 and 2000' and 'Less than 1000'.We would like to understand 3 different levels of customers based on the amount associated with their purchases. The top level includes anyone with a Lifetime Value (total sales of all orders)
greater than 200,000
usd. The second level is between200,000 and 100,000
usd. The lowest level is anyoneunder 100,000
usd. Provide a table that includes the level associated with each account. You should provide the account name, the total sales of all orders for the customer, and the level. Order with the top spending customers listed first.We would now like to perform a similar calculation to the first, but we want to obtain the total amount spent by customers only in
2016
and2017
. Keep the same levels as in the previous question. Order with the top spending customers listed first.We would like to identify top performing sales reps, which are sales reps associated with more than 200 orders. Create a table with the sales rep name, the total number of orders, and a column with
top
ornot
depending on if they have more than 200 orders. Place the top sales people first in your final table.The previous didn't account for the middle, nor the dollar amount associated with the sales. Management decides they want to see these characteristics represented as well. We would like to identify top performing sales reps, which are sales reps associated with more than
200
orders or more than750000
in total sales. Themiddle
group has any rep with more than 150 orders or500000
in sales. Create a table with the sales rep name, the total number of orders, total sales across all orders, and a column withtop
,middle
, orlow
depending on this criteria. Place the top sales people based on dollar amount of sales first in your final table. You might see a few upset sales people by this criteria!
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: sql-evaluator
- Opened files (when workspace is loaded): n/a